package com.hemerasolutions.v2trainer.service;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.PostConstruct;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import com.hemerasolutions.v2trainer.dao.ExceptionDao;
import com.hemerasolutions.v2trainer.dao.interfaces.AdminDaoInterface;
import com.hemerasolutions.v2trainer.dao.interfaces.AssociationETDaoInterface;
import com.hemerasolutions.v2trainer.dao.interfaces.BodyRegionDaoInterface;
import com.hemerasolutions.v2trainer.dao.interfaces.ExecutionDaoInterface;
import com.hemerasolutions.v2trainer.dao.interfaces.IntensityUnitDaoInterface;
import com.hemerasolutions.v2trainer.dao.interfaces.LibraryDaoInterface;
import com.hemerasolutions.v2trainer.dao.interfaces.ModalityDaoInterface;
import com.hemerasolutions.v2trainer.dao.interfaces.PhotoDaoInterface;
import com.hemerasolutions.v2trainer.dao.interfaces.PhysicalCapacityDaoInterface;
import com.hemerasolutions.v2trainer.dao.interfaces.RemoteVideoDaoInterface;
import com.hemerasolutions.v2trainer.dao.interfaces.RoleDaoInterface;
import com.hemerasolutions.v2trainer.dao.interfaces.RpeDaoInterface;
import com.hemerasolutions.v2trainer.dao.interfaces.StatisticUnitDaoInterface;
import com.hemerasolutions.v2trainer.dao.interfaces.ThemeDaoInterface;
import com.hemerasolutions.v2trainer.dao.interfaces.TrainingTypeDaoInterface;
import com.hemerasolutions.v2trainer.dao.interfaces.UserDaoInterface;
import com.hemerasolutions.v2trainer.dao.interfaces.VideoDaoInterface;
import com.hemerasolutions.v2trainer.dao.interfaces.VolumeFactorDaoInterface;
import com.hemerasolutions.v2trainer.dao.interfaces.VolumeTypeDaoInterface;
import com.hemerasolutions.v2trainer.model.exercise.PhysicalCapacity;
import com.hemerasolutions.v2trainer.model.exercise.executions.AssociationET;
import com.hemerasolutions.v2trainer.model.exercise.executions.Execution;
import com.hemerasolutions.v2trainer.model.library.Library;
import com.hemerasolutions.v2trainer.model.multimedia.Photo;
import com.hemerasolutions.v2trainer.model.multimedia.RemoteVideo;
import com.hemerasolutions.v2trainer.model.muscle.BodyRegion;
import com.hemerasolutions.v2trainer.model.muscle.Muscle;
import com.hemerasolutions.v2trainer.model.muscle.MuscleGroup;
import com.hemerasolutions.v2trainer.model.others.Theme;
import com.hemerasolutions.v2trainer.model.security.AccessRole;
import com.hemerasolutions.v2trainer.model.training.TrainingType;
import com.hemerasolutions.v2trainer.model.training.statistic.StatisticUnit;
import com.hemerasolutions.v2trainer.model.unit.intensity.IntensityUnit;
import com.hemerasolutions.v2trainer.model.unit.intensity.Rpe;
import com.hemerasolutions.v2trainer.model.unit.volume.VolumeFactor;
import com.hemerasolutions.v2trainer.model.unit.volume.VolumeType;
import com.hemerasolutions.v2trainer.model.users.Admin;
import com.hemerasolutions.v2trainer.model.users.User;
import com.hemerasolutions.v2trainer.service.interfaces.StartUpServiceInterface;

@Service("startUpService")
@Scope("singleton")
public class StartUpService extends BaseService implements StartUpServiceInterface {

	private static final long serialVersionUID = 1L;

	@Autowired
	private BodyRegionDaoInterface bodyDao;
	
	@Autowired
	private ThemeDaoInterface themeDao;

	@Autowired
	private PhotoDaoInterface photoDao;

	@Autowired
	private VideoDaoInterface videoDao;
	
	@Autowired 
	private ModalityDaoInterface modalityDao;
	
	@Autowired
	private LibraryDaoInterface libraryDao;
	
	@Autowired
	private TrainingTypeDaoInterface ttDao;
	
	@Autowired
	private ExecutionDaoInterface executionDao;
	
	@Autowired
	private VolumeTypeDaoInterface volumeTypeDao;
	
	@Autowired
	private VolumeFactorDaoInterface volumeFactorDao;
	
	@Autowired
	private IntensityUnitDaoInterface iuDao;
	
	@Autowired
	private AdminDaoInterface adminDao;
	
	@Autowired
	private UserDaoInterface userDao;
	
	@Autowired
	private RoleDaoInterface roleDao;
		
	@Autowired
	private AssociationETDaoInterface assocETDao;
	
	@Autowired
	private PhysicalCapacityDaoInterface pcDao;
	
	@Autowired
	private RpeDaoInterface rpeDao;
	
	@Autowired
	private RemoteVideoDaoInterface  remoteVideoDao;

	@Autowired
	private StatisticUnitDaoInterface statisticUnitDao;
	
	public StartUpService() {
		super();
	}

	@PostConstruct
	public void init(){
		
		this.initThemes();
		this.initPhoto();
		this.initVideos();
		this.initModalityBase();
		this.initRoles();
		this.initAdmin();
		
		
		this.initDevData();
		
	}


	private void initVideos() {
		if(	this.remoteVideoDao.list().isEmpty()){
			List<RemoteVideo> rvs = new ArrayList<RemoteVideo>();
			RemoteVideo rv = new RemoteVideo();
			
			rv.setUuid(RemoteVideo.DEFAULT_EQUIPMENT_VIDEO_UUID);
			rvs.add(rv);
			
			rv = new RemoteVideo();

			rv.setUuid(RemoteVideo.DEFAULT_EXERCISE_VIDEO_UUID);
			rvs.add(rv);
			
			remoteVideoDao.save(rvs);
		}
		
	}

	private void initRoles() {
		if(this.roleDao.list().isEmpty()){
			
			List<AccessRole> roles = new ArrayList<AccessRole>();
			AccessRole role;
			
			role = new AccessRole();
			role.setName("ROLE_ADMIN");
			roles.add(role);			

			role = new AccessRole();
			role.setName("ROLE_ACADEMY");
			roles.add(role);			

			role = new AccessRole();
			role.setName("ROLE_TEACHER");
			roles.add(role);			
			
			role = new AccessRole();
			role.setName("ROLE_PERSONAL");
			roles.add(role);			
	
			role = new AccessRole();
			role.setName("ROLE_ATHLETE");
			roles.add(role);			

			role = new AccessRole();
			role.setName("ROLE_GRAPHICS");
			roles.add(role);			

			role = new AccessRole();
			role.setName("ROLE_REPORTS");
			roles.add(role);			

			role = new AccessRole();
			role.setName("ROLE_MEDIC");
			roles.add(role);			

			role = new AccessRole();
			role.setName("ROLE_PRESCRIPTION");
			roles.add(role);			

			role = new AccessRole();
			role.setName("ROLE_PLANNING");
			roles.add(role);			
			
			roleDao.save(roles);

		}
		
	}

	private void initAdmin() {
		if(this.adminDao.list().isEmpty()){
			Admin admin = new Admin();
			User user = new User();
			
			user.setEmail("admin@v2trainer.com");
			user.setPassword("admin");
			user.setUserType(User.USERTYPE_ADMIN);
			user.getRoles().add(roleDao.getByName("ROLE_ADMIN"));

			
			Library lib = new Library();
			lib.setOwner(user);
			lib.setDefaultLibrary(true);
			lib.setName("default");
			user.getLibrarys().add(lib);
			
			admin.setPhoto(photoDao.findByLocation("user_photo.jpg"));
			admin.setTheme(themeDao.list().get(0));
			admin.setUser(this.userDao.save(user));
			
			
			adminDao.save(admin);
		}	
			
		
	}

	private void initModalityBase() {

		this.initRpe();
		this.initVolumeTypes();
		this.initIntensityUnits();
		this.initExecutions();
		this.initTrainingTypes();
		this.initCrossTtExevItensity();
		this.initMuscles();
		this.initStatistics();
		
		
	}

	private void initStatistics() {
		if(this.statisticUnitDao.list().isEmpty()){
			List<StatisticUnit> statisticUnits = new ArrayList<StatisticUnit>();
			
			statisticUnits.add(new StatisticUnit(StatisticUnit.SU_TYPE_A,"ARBITRARY_UNIT_A","ARBITRARY_UNIT_DESC_A"));
			statisticUnits.add(new StatisticUnit(StatisticUnit.SU_TYPE_B,"ARBITRARY_UNIT_B","ARBITRARY_UNIT_DESC_B"));
			statisticUnits.add(new StatisticUnit(StatisticUnit.SU_TYPE_C,"ARBITRARY_UNIT_C","ARBITRARY_UNIT_DESC_C"));
			statisticUnits.add(new StatisticUnit(StatisticUnit.SU_TYPE_D,"ARBITRARY_UNIT_D","ARBITRARY_UNIT_DESC_D"));
			statisticUnits.add(new StatisticUnit(StatisticUnit.SU_TYPE_E,"ARBITRARY_UNIT_E","ARBITRARY_UNIT_DESC_E"));
			statisticUnits.add(new StatisticUnit(StatisticUnit.SU_TYPE_F,"ARBITRARY_UNIT_F","ARBITRARY_UNIT_DESC_F"));

			statisticUnitDao.save(statisticUnits);
		}
		
	}

	private void initRpe() {
		if(this.rpeDao.list().isEmpty()){
			List<Rpe> rpes = new ArrayList<Rpe>();

			rpes.add(new Rpe(0,"RPE0_NAME","RPE0_DESCRIPTION"));
			rpes.add(new Rpe(1,"RPE1_NAME","RPE1_DESCRIPTION"));
			rpes.add(new Rpe(2,"RPE2_NAME","RPE2_DESCRIPTION"));
			rpes.add(new Rpe(3,"RPE3_NAME","RPE3_DESCRIPTION"));
			rpes.add(new Rpe(4,"RPE4_NAME","RPE4_DESCRIPTION"));
			rpes.add(new Rpe(5,"RPE5_NAME","RPE5_DESCRIPTION"));
			rpes.add(new Rpe(6,"RPE6_NAME","RPE6_DESCRIPTION"));
			rpes.add(new Rpe(7,"RPE7_NAME","RPE7_DESCRIPTION"));
			rpes.add(new Rpe(8,"RPE8_NAME","RPE8_DESCRIPTION"));
			rpes.add(new Rpe(9,"RPE9_NAME","RPE9_DESCRIPTION"));
			rpes.add(new Rpe(10,"RPE10_NAME","RPE10_DESCRIPTION"));
						
			this.rpeDao.save(rpes);
			
		}
		
	}

	private void initMuscles() {

		if(bodyDao.list().isEmpty()){
			List<BodyRegion> brs = new ArrayList<BodyRegion>();
			BodyRegion br;
			MuscleGroup mg;	

		
			br = new BodyRegion("BR_HEAD",new Photo());
			mg = new MuscleGroup(br,"MG_SUBCUTANEOUS_HEAD",new Photo());
			mg.getMuscles().add(new Muscle(mg,"MUSC_OCCIPITOFRONTAL",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_TEMPOROPARIETAL",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_AURICULAR",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_ORBICULARIS_OCULI",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_CORRUGATOR_SUPERCILII",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_PROCERUS",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_NASAL",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_DOWN_FROM_NASAL_SEPTUM",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_BUCCINATOR",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_ORBICULARIS_ORIS",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_LEVATOR_ANGULI_ORIS",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_DEPRESSOR_ANGULI_ORIS",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_LIFTER_OF_THE_UPPER_LIP",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_DEPRESSOR_OF_THE_LOWER_LIP",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_LIFTER_OF_THE_UPPER_LIP_AND_WING_NOSE",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_ZYGOMATIC_MAJOR",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_ZYGOMATIC_MINOR",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_MENTUAL",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_RISORIUS_SANTORINI",new Photo()));
			br.getMuscleGroups().add(mg);

			mg = new MuscleGroup(br,"MG_CHEWING",new Photo());
			mg.getMuscles().add(new Muscle(mg,"MUSC_MASSETER",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_TEMPORAL",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_LATERAL_PTERYGOID",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_MEDIAL_PTERYGOID",new Photo()));
			br.getMuscleGroups().add(mg);

			mg = new MuscleGroup(br,"MG_SENSES",new Photo());
			mg.getMuscles().add(new Muscle(mg,"MUSC_UPPER_EYELID_LIFTER_FROM",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_SUPERIOR_TARSAL",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_SUPERIOR_RECTUS",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_INFERIOR_RECTUS",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_MEDIAL_RECTUS",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_STRAIGHT_SIDE",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_SUPERIOR_OBLIQUE",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_INFERIOR_OBLIQUE",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_THE_DILATOR_OF_THE_PUPIL",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_PUPIL_SPHINCTER",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_CILIARY",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_STAPES",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_TENSOR_TYMPANI",new Photo()));
			br.getMuscleGroups().add(mg);

			mg = new MuscleGroup(br,"MG_LIGUA_VISCERAL_AND_PALATE",new Photo());
			mg.getMuscles().add(new Muscle(mg,"MUSC_GENIOGLOSSUS",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_HYOGLOSSAL",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_CONDROGLOSSO",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_STYLOGLOSSUS",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_SUPERIOR_LONGITUDINAL",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_LONGITUDINAL_BOTTOM",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_TRANSVERSE",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_VERTICAL",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_LIFTER_VEIL_PALATINO",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_TENSOR_VEIL_PALATINO",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_THE_UVULA",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_PALATOGLOSSUS",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_PALATOPHARYNGEAL",new Photo()));
			br.getMuscleGroups().add(mg);
			brs.add(br);

			br = new BodyRegion("BR_NECK",new Photo());
			mg = new MuscleGroup(br,"MG_CERVICAL",new Photo());
			mg.getMuscles().add(new Muscle(mg,"MUSC_PLATISMA",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_STERNOCLEIDOMASTOID",new Photo()));
			br.getMuscleGroups().add(mg);
			
			mg = new MuscleGroup(br,"MG_SUPRAHYOID",new Photo());
			mg.getMuscles().add(new Muscle(mg,"MUSC_DIGASTRIC",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_STYLE_HYOID",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_MYLOHYOID",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_GENIOHYOID",new Photo()));
			br.getMuscleGroups().add(mg);
			
			mg = new MuscleGroup(br,"MG_INFRAHYOID",new Photo());
			mg.getMuscles().add(new Muscle(mg,"MUSC_STERNOHYOID",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_STERNOTHYREOID",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_THYRO_HYOID",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_OMO_HYOID",new Photo()));
			br.getMuscleGroups().add(mg);
			

			mg = new MuscleGroup(br,"MG_ANTERIOR_VERTEBRAL",new Photo());
			mg.getMuscles().add(new Muscle(mg,"MUSC_ALONG_THE_COLORADO",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_THE_LONG_HEAD",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_STRAIGHT_BACK_OF_HEAD",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_STRAIGHT_SIDE_OF_HEAD",new Photo()));
			br.getMuscleGroups().add(mg);

			mg = new MuscleGroup(br,"MG_LATERAL_VERTEBRAL",new Photo());
			mg.getMuscles().add(new Muscle(mg,"MUSC_PREVIOUS_SCALENE",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_MIDDLE_SCALENE",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_LATER_SCALENE",new Photo()));
			br.getMuscleGroups().add(mg);
			

			mg = new MuscleGroup(br,"MG_VISCERAL",new Photo());
			mg.getMuscles().add(new Muscle(mg,"MUSC_LOWER_PHARYNGEAL_CONSTRICTORS",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_FROM_EASTERN_PHARYNX_CONSTRICTORS",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_FROM_SUPERIOR_CONSTRICTOR_PHARYNX",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_STYLOPHARYNGEUS",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_SALPINGOPHARYNGEAL",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_CRICOTHYROID",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_POSTERIOR_CRICOARYTENOID",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_LATERAL_CRICOARYTENOID",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_ARYTENOID",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_THYROARITENOID",new Photo()));
			br.getMuscleGroups().add(mg);
			brs.add(br);		

			br = new BodyRegion("BR_TRUNK",new Photo());
			mg = new MuscleGroup(br,"MG_BACK",new Photo());
			mg.getMuscles().add(new Muscle(mg,"MUSC_ESPLÊNIOS_OF_HEAD",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_CERVICAL_ESPLÊNIOS",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_ERECTOR_SPINE",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_LARGE_NUMBER",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_ESPLÊNIOS",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_INTERSPINAIS",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_INTERTRANSVERSO",new Photo()));
			br.getMuscleGroups().add(mg);
			
			mg = new MuscleGroup(br,"MG_SUBOCCIPITAL",new Photo());
			mg.getMuscles().add(new Muscle(mg,"MUSC_STRAIGHT_FROM_THE_HEAD",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_FROM_OBLIQUE_HEAD",new Photo()));
			br.getMuscleGroups().add(mg);

			mg = new MuscleGroup(br,"MG_CHEST",new Photo());
			mg.getMuscles().add(new Muscle(mg,"MUSC_INTERCOSTAL",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_SUBCOSTAL",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_THE_THORAX_TRANSVERSE",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_LIFTERS_OF_RIBS",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_LATER_SERRÁTEIS",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_DIAPHRAGM",new Photo()));
			br.getMuscleGroups().add(mg);
			
			mg = new MuscleGroup(br,"MG_STOMACH",new Photo());
			mg.getMuscles().add(new Muscle(mg,"MUSC_PREVIOUS_SIDE",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_SIDE_WALL",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_EXTERNAL_OBLIQUE",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_INTERNAL_OBLIQUE",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_TRANSVERSUS_ABDOMINIS",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_RECTUS_ABDOMINIS",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_PYRAMIDAL",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_SQUARE_LUMBAR",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_PSOAS_MAJOR",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_PSOAS_MINOR",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_ILIAC",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_CREMASTER",new Photo()));
			br.getMuscleGroups().add(mg);

			mg = new MuscleGroup(br,"MG_PELVIS_FLOOR",new Photo());
			mg.getMuscles().add(new Muscle(mg,"MUSC_ILIOCOCCYGEAL",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_PUBOCOCCYGEUS",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_PUBORECTAL",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_COCCYGEAL",new Photo()));
			br.getMuscleGroups().add(mg);
			
			mg = new MuscleGroup(br,"MG_PERINEUM",new Photo());
			mg.getMuscles().add(new Muscle(mg,"MUSC_SUPERFICIAL_PERINEAL_SPACE",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_DEEP_PERINEAL_SPACE",new Photo()));
			br.getMuscleGroups().add(mg);
			brs.add(br);		

			
			br = new BodyRegion("BR_UPPER_LIMBS",new Photo());
			mg = new MuscleGroup(br,"MG_SPINE",new Photo());
			mg.getMuscles().add(new Muscle(mg,"MUSC_TRAPEZE",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_LARGE_NUMBER",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_BIGGEST_RHOMBOID",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_RHOMBOID_MINOR",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_LEVATOR_SCAPULAE",new Photo()));
			br.getMuscleGroups().add(mg);

			mg = new MuscleGroup(br,"MG_THORACIC_CAVITY",new Photo());
			mg.getMuscles().add(new Muscle(mg,"MUSC_PECTORALIS_MAJOR",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_PECTORAL_MINOR",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_SUBCLAVIAN",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_PREVIOUS_SERRATUS",new Photo()));
			br.getMuscleGroups().add(mg);

			mg = new MuscleGroup(br,"MG_SHOULDER",new Photo());
			mg.getMuscles().add(new Muscle(mg,"MUSC_DELTOID",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_SUPRA_SPINAL",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_SPINAL_INFRASTRUCTURE",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_LOWEST_ROUND",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_SUBSCAPULARIS",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_BIGGEST_ROUND",new Photo()));
			br.getMuscleGroups().add(mg);

			mg = new MuscleGroup(br,"MG_PREVIOUS_ARM",new Photo());
			mg.getMuscles().add(new Muscle(mg,"MUSC_CORACOBRACHIALIS",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_BRACHIAL_BICEPS",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_BRACHIAL",new Photo()));
			br.getMuscleGroups().add(mg);

			mg = new MuscleGroup(br,"MG_POSTERIOR_ARM",new Photo());
			mg.getMuscles().add(new Muscle(mg,"MUSC_BRACHIAL_TRICEPS",new Photo()));
			br.getMuscleGroups().add(mg);

			mg = new MuscleGroup(br,"MG_PREVIOUS_FOREARM",new Photo());
			mg.getMuscles().add(new Muscle(mg,"MUSC_SUPERFICIAL",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_PRONATOR_ROUND",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_PALMAR_LONG",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_FLEXOR_CARPI_RADIALIS",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_ULNAR_FLEXOR_CARPI",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_SUPERFICIAL_FLEXOR_FINGERS",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_DEEP",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_PRONATOR_SQUARE",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_FLEXOR_DEEP_FINGERS",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_LONG_FLEXOR_THUMB",new Photo()));
			br.getMuscleGroups().add(mg);

			mg = new MuscleGroup(br,"MG_POSTERIOR_FOREARM",new Photo());
			mg.getMuscles().add(new Muscle(mg,"MUSC_SUPERFICIAL",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_BRACHIORADIALIS",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_RADIAL_LONG_EXTENSOR_CARPI",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_SHORT_CARPAL",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_EXTENSOR_DIGITORUM",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_FINGER_EXTENSOR_LOW",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_ULNAR_EXTENSOR_CARPI",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_DEEP",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_SUPINATOR",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_LONG_THUMB_ABDUCTOR",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_EXTENDER_SHORT_THUMB",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_EXTENDER_LONG_THUMB",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_THE_EXTENDER_INDEX",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_ANCONEUS",new Photo()));
			br.getMuscleGroups().add(mg);
			
			mg = new MuscleGroup(br,"MG_HAND",new Photo());
			mg.getMuscles().add(new Muscle(mg,"MUSC_OPPONENT_THUMB",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_FLEXOR_SHORT_THUMB",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_SHORT_THUMB_ABDUCTOR",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_POLLICIS",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_OPPONENT_OF_LOW",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_FLEXOR_SHORT_OF_LOW",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_FROM_MINIMUM_ABDUCTOR",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_PALMAR_BRIEF",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_LUMBRICALES",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_DORSAL_INTEROSSEOUS",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_INTEROSSEOUS_PALMARES",new Photo()));
			br.getMuscleGroups().add(mg);
			brs.add(br);		
			
			br = new BodyRegion("BR_LOWER_LIMBS",new Photo());
			mg = new MuscleGroup(br,"MG_HIP",new Photo());
			mg.getMuscles().add(new Muscle(mg,"MUSC_PSOAS_MAJOR",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_PSOAS_MINOR",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_ILIAC",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_GLUTEUS_MAXIMUS",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_MIDDLE_GLUTEAL",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_MINIMUM_GLUTEUS",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_PIRIFORMIS",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_LOWER_TWIN",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_SUPERIOR_TWIN",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_INTERNAL_SHUTTER",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_EXTERNAL_SHUTTER",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_SQUARE_LUMBAR",new Photo()));
			br.getMuscleGroups().add(mg);
			
			mg = new MuscleGroup(br,"MG_THIGH",new Photo());
			mg.getMuscles().add(new Muscle(mg,"MUSC_SARTORIUS_TENSOR_FASCIA_LATA",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_QUADRICEPS_FEMORAL",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_PECTINEUS",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_GRACILIS",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_LONG_PIPELINE",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_SHORT_ADDUCTOR",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_ADDUCTOR_MAGNUS",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_FEMORAL_BICEPS",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_SEMITENDINOSUS",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_SEMIMEMBRANOSUS",new Photo()));
			br.getMuscleGroups().add(mg);
			
			mg = new MuscleGroup(br,"MG_LEG",new Photo());
			mg.getMuscles().add(new Muscle(mg,"MUSC_ANTERIOR_TIBIALIS",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_EXTENSOR_HALLUCIS_LONGUS",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_EXTENSOR_DIGITORUM_LONGUS",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_THIRD_FIBULAR",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_LOCA_SIDE_OF_LONG_LEG_FIBULAR",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_SHORT_FIBULAR",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_TRICEPS_SURAL",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_PLANT",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_FLEXOR_HALLUCIS_LONGUS",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_COMMON_FLEXOR_DIGITORUM_LONGUS",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_POSTERIOR_TIBIAL",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_POPLITEAL",new Photo()));
			br.getMuscleGroups().add(mg);

			mg = new MuscleGroup(br,"MG_FOOT",new Photo());
			mg.getMuscles().add(new Muscle(mg,"MUSC_EXTENDER_SHORT_FINGERS",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_ABDUCTOR_HALLUCIS",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_ADDUCTOR_HALLUCIS",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_FLEXOR_HALLUCIS",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_THE_ABDUCTOR_V_FINGER",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_SHORT_FINGER_FLEXOR_OF_V",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_OPPONENT_FROM_V_FINGER",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_SHORT_PLANTAR_FLEXOR",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_SQUARE_PLANTING",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_LUMBRICOIDES",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_PLANTAR_INTEROSSEOUS",new Photo()));
			mg.getMuscles().add(new Muscle(mg,"MUSC_DORSAL_INTEROSSEOUS",new Photo()));
			br.getMuscleGroups().add(mg);
			brs.add(br);		
			
			bodyDao.save(brs);
			
			
		}
	}

	private void initCrossTtExevItensity() {
		if(this.assocETDao.list().isEmpty()){
			
			List<AssociationET> assocs = new ArrayList<AssociationET>();
			AssociationET assoc;
			List<IntensityUnit> units; 
			
			assoc = new AssociationET();
			units = new ArrayList<IntensityUnit>();
			assoc.setTrainingType(ttDao.getByName("TT_STRENGTH"));
			assoc.setExecution(executionDao.getByName("E_DYNAMIC"));
			units.add(iuDao.getByName("IU_1RM_PERCENT"));
			units.add(iuDao.getByName("IU_RM"));
			units.add(iuDao.getByName("IU_LOAD_RM"));
			units.add(iuDao.getByName("IU_MAX_TIME"));
			units.add(iuDao.getByName("IU_MAX_TIME_LOADED"));
			units.add(iuDao.getByName("IU_BORG"));
			units.add(iuDao.getByName("IU_HERTZ"));
			units.add(iuDao.getByName("IU_LOAD"));
			assoc.setIntensityUnits(units);
			assocs.add(assoc);
			
			assoc = new AssociationET();
			units = new ArrayList<IntensityUnit>();
			assoc.setTrainingType(ttDao.getByName("TT_STRENGTH"));
			assoc.setExecution(executionDao.getByName("E_ECCENTRIC"));
			units.add(iuDao.getByName("IU_1RM_PERCENT"));
			units.add(iuDao.getByName("IU_RM"));
			units.add(iuDao.getByName("IU_LOAD_RM"));
			units.add(iuDao.getByName("IU_MAX_TIME"));
			units.add(iuDao.getByName("IU_MAX_TIME_LOADED"));
			units.add(iuDao.getByName("IU_BORG"));
			units.add(iuDao.getByName("IU_HERTZ"));
			units.add(iuDao.getByName("IU_LOAD"));
			assoc.setIntensityUnits(units);
			assocs.add(assoc);

			assoc = new AssociationET();
			units = new ArrayList<IntensityUnit>();
			assoc.setTrainingType(ttDao.getByName("TT_STRENGTH"));
			assoc.setExecution(executionDao.getByName("E_ISOMETRIC"));
			units.add(iuDao.getByName("IU_MAX_TIME"));
			units.add(iuDao.getByName("IU_MAX_TIME_PERCENT"));
			units.add(iuDao.getByName("IU_MAX_TIME_LOADED"));
			units.add(iuDao.getByName("IU_MAX_TIME_LOADED_PERCENT"));
			units.add(iuDao.getByName("IU_BORG"));
			units.add(iuDao.getByName("IU_HERTZ"));
			units.add(iuDao.getByName("IU_LOAD"));
			assoc.setIntensityUnits(units);			
			assocs.add(assoc);
			
			
			assoc = new AssociationET();
			units = new ArrayList<IntensityUnit>();
			assoc.setTrainingType(ttDao.getByName("TT_LOCOMOTION"));
			assoc.setExecution(executionDao.getByName("E_DYNAMIC"));
			units.add(iuDao.getByName("IU_SPEED"));
			units.add(iuDao.getByName("IU_SPEED_PERCENT"));
			units.add(iuDao.getByName("IU_POTENCY"));
			units.add(iuDao.getByName("IU_POTENCY_PERCENT"));
			units.add(iuDao.getByName("IU_FC"));
			units.add(iuDao.getByName("IU_FC_PERCENT"));
			units.add(iuDao.getByName("IU_VO2"));
			units.add(iuDao.getByName("IU_VO2_MAX_PERCENT"));
			units.add(iuDao.getByName("IU_BORG"));
			units.add(iuDao.getByName("IU_LACTATE_THRESHOLD"));
			units.add(iuDao.getByName("IU_KCAL"));
			assoc.setIntensityUnits(units);			
			assocs.add(assoc);

			assoc = new AssociationET();
			units = new ArrayList<IntensityUnit>();
			assoc.setTrainingType(ttDao.getByName("TT_FLEXIBILITY"));
			assoc.setExecution(executionDao.getByName("E_STATIC"));
			units.add(iuDao.getByName("IU_MAX_TIME"));
			units.add(iuDao.getByName("IU_MAX_TIME_PERCENT"));
			units.add(iuDao.getByName("IU_MAX_TIME_LOADED"));
			units.add(iuDao.getByName("IU_MAX_TIME_LOADED_PERCENT"));
			units.add(iuDao.getByName("IU_LOAD"));
			assoc.setIntensityUnits(units);			
			assocs.add(assoc);
			
			assoc = new AssociationET();
			units = new ArrayList<IntensityUnit>();
			assoc.setTrainingType(ttDao.getByName("TT_FLEXIBILITY"));
			assoc.setExecution(executionDao.getByName("E_DYNAMIC"));
			units.add(iuDao.getByName("IU_LOAD"));
			units.add(iuDao.getByName("IU_1RM_PERCENT"));
			units.add(iuDao.getByName("IU_RM"));
			units.add(iuDao.getByName("IU_LOAD_RM"));
			units.add(iuDao.getByName("IU_KCAL"));
			assoc.setIntensityUnits(units);			
			assocs.add(assoc);

			
			assoc = new AssociationET();
			units = new ArrayList<IntensityUnit>();
			assoc.setTrainingType(ttDao.getByName("TT_PLYOMETRIC"));
			assoc.setExecution(executionDao.getByName("E_BILATERAL"));
			units.add(iuDao.getByName("IU_MAX_JUMP"));
			units.add(iuDao.getByName("IU_MAX_JUMP_LOADED"));
			units.add(iuDao.getByName("IU_MAX_JUMP_PERCENT"));
			units.add(iuDao.getByName("IU_MAX_JUMP_LOADED_PERCENT"));
			units.add(iuDao.getByName("IU_MAX_ACTION"));
			units.add(iuDao.getByName("IU_MAX_ACTION_PERCENT"));
			assoc.setIntensityUnits(units);			
			assocs.add(assoc);
			
			assoc = new AssociationET();
			units = new ArrayList<IntensityUnit>();
			assoc.setTrainingType(ttDao.getByName("TT_PLYOMETRIC"));
			assoc.setExecution(executionDao.getByName("E_UNILATERAL"));
			units.add(iuDao.getByName("IU_MAX_JUMP"));
			units.add(iuDao.getByName("IU_MAX_JUMP_LOADED"));
			units.add(iuDao.getByName("IU_MAX_JUMP_PERCENT"));
			units.add(iuDao.getByName("IU_MAX_JUMP_LOADED_PERCENT"));
			units.add(iuDao.getByName("IU_MAX_ACTION"));
			units.add(iuDao.getByName("IU_MAX_ACTION_PERCENT"));
			assoc.setIntensityUnits(units);			
			assocs.add(assoc);
			
			this.assocETDao.save(assocs);
		}
		
	}

	private List<IntensityUnit> initIntensityUnits() {

		List<IntensityUnit> ius;
		
		ius = iuDao.list();
		

		if(ius.isEmpty()){
			
			ius.add(new IntensityUnit(1,IntensityUnit.IU_TYPE_PERFORMANCE,"IU_1RM_PERCENT","IU_1RM_PERCENT_DESC",volumeTypeDao.getByName("V_PERCENT"),volumeFactorDao.getByName("VF_PERCENT")));
			ius.add(new IntensityUnit(2,IntensityUnit.IU_TYPE_PERFORMANCE,"IU_1RM_PERCENT_RM","IU_1RM_PERCENT_RM_DESC",volumeTypeDao.getByName("V_PERCENT"),volumeFactorDao.getByName("VF_PERCENT")));
			ius.add(new IntensityUnit(3,IntensityUnit.IU_TYPE_PERFORMANCE,"IU_AMPLITUDE","IU_AMPLITUDE_DESC",volumeTypeDao.getByName("V_DISTANCE"),volumeFactorDao.getByName("VF_DISTANCE_MM")));
			ius.add(new IntensityUnit(4,IntensityUnit.IU_TYPE_PERFORMANCE,"IU_EXAUSTION_TIME","IU_EXAUSTION_TIME_DESC",volumeTypeDao.getByName("V_TIME"),volumeFactorDao.getByName("VF_TIME")));
			ius.add(new IntensityUnit(5,IntensityUnit.IU_TYPE_PHYSIOLOGIC,"IU_FC","IU_FC_DESC",volumeTypeDao.getByName("V_BPM"),volumeFactorDao.getByName("VF_BPM")));
			ius.add(new IntensityUnit(6,IntensityUnit.IU_TYPE_PHYSIOLOGIC,"IU_FC_PERCENT","IU_FC_PERCENT_DESC",volumeTypeDao.getByName("V_PERCENT"),volumeFactorDao.getByName("VF_PERCENT")));
			ius.add(new IntensityUnit(7,IntensityUnit.IU_TYPE_PERFORMANCE,"IU_FREQUENCY","IU_FREQUENCY_DESC",volumeTypeDao.getByName("V_HEARTZ"),volumeFactorDao.getByName("VF_HZ")));
			ius.add(new IntensityUnit(8,IntensityUnit.IU_TYPE_PERFORMANCE,"IU_JUMP","IU_JUMP_DESC",volumeTypeDao.getByName("V_DUMMY"),volumeFactorDao.getByName("VF_DUMMY")));
			ius.add(new IntensityUnit(9,IntensityUnit.IU_TYPE_PERFORMANCE,"IU_JUMP_PERCENT","IU_JUMP_PERCENT_DESC",volumeTypeDao.getByName("V_PERCENT"),volumeFactorDao.getByName("VF_PERCENT")));
			ius.add(new IntensityUnit(10,IntensityUnit.IU_TYPE_PHYSIOLOGIC,"IU_LACTATE_THRESHOLD","IU_LACTATE_THRESHOLD_DESC",volumeTypeDao.getByName("V_DUMMY"),volumeFactorDao.getByName("VF_DUMMY")));
			ius.add(new IntensityUnit(11,IntensityUnit.IU_TYPE_PERFORMANCE,"IU_LOAD","IU_LOAD_DESC",volumeTypeDao.getByName("V_WEIGHT"),volumeFactorDao.getByName("VF_KG")));
			ius.add(new IntensityUnit(12,IntensityUnit.IU_TYPE_PERFORMANCE,"IU_LOAD_RM","IU_LOAD_RM_DESC",volumeTypeDao.getByName("V_WEIGHT"),volumeFactorDao.getByName("VF_KG")));
			ius.add(new IntensityUnit(13,IntensityUnit.IU_TYPE_PERFORMANCE,"IU_MAX_ACTION","IU_MAX_ACTION_DESC",volumeTypeDao.getByName("V_REPETITION"),volumeFactorDao.getByName("VF_REPETITION")));
			ius.add(new IntensityUnit(14,IntensityUnit.IU_TYPE_PERFORMANCE,"IU_MAX_ACTION_PERCENT","IU_MAX_ACTION_PERCENT_DESC",volumeTypeDao.getByName("V_PERCENT"),volumeFactorDao.getByName("VF_PERCENT")));
			ius.add(new IntensityUnit(15,IntensityUnit.IU_TYPE_PERFORMANCE,"IU_MAX_ACTION_PERCENT","IU_MAX_ACTION_PERCENT_DESC",volumeTypeDao.getByName("V_PERCENT"),volumeFactorDao.getByName("VF_PERCENT")));
			ius.add(new IntensityUnit(16,IntensityUnit.IU_TYPE_PERFORMANCE,"IU_MAX_JUMP","IU_MAX_JUMP_DESC",volumeTypeDao.getByName("V_DISTANCE"),volumeFactorDao.getByName("VF_DISTANCE_MM")));
			ius.add(new IntensityUnit(17,IntensityUnit.IU_TYPE_PERFORMANCE,"IU_MAX_JUMP_LOADED","IU_MAX_JUMP_LOADED_DESC",volumeTypeDao.getByName("V_DISTANCE"),volumeFactorDao.getByName("VF_DISTANCE_MM")));
			ius.add(new IntensityUnit(18,IntensityUnit.IU_TYPE_PERFORMANCE,"IU_MAX_JUMP_LOADED_PERCENT","IU_MAX_JUMP_LOADED_PERCENT_DESC",volumeTypeDao.getByName("V_PERCENT"),volumeFactorDao.getByName("VF_PERCENT")));
			ius.add(new IntensityUnit(19,IntensityUnit.IU_TYPE_PERFORMANCE,"IU_MAX_JUMP_PERCENT","IU_MAX_JUMP_PERCENT_DESC",volumeTypeDao.getByName("V_PERCENT"),volumeFactorDao.getByName("VF_PERCENT")));
			ius.add(new IntensityUnit(20,IntensityUnit.IU_TYPE_PERFORMANCE,"IU_MAX_KCAL_PERCENT","IU_MAX_KCAL_PERCENT_DESC",volumeTypeDao.getByName("V_PERCENT"),volumeFactorDao.getByName("VF_PERCENT")));
			ius.add(new IntensityUnit(21,IntensityUnit.IU_TYPE_PERFORMANCE,"IU_MAX_TIME","IU_MAX_TIME_DESC",volumeTypeDao.getByName("V_TIME"),volumeFactorDao.getByName("VF_TIME")));
			ius.add(new IntensityUnit(22,IntensityUnit.IU_TYPE_PERFORMANCE,"IU_MAX_TIME_LOADED","IU_MAX_TIME_LOADED_DESC",volumeTypeDao.getByName("V_TIME"),volumeFactorDao.getByName("VF_TIME")));
			ius.add(new IntensityUnit(23,IntensityUnit.IU_TYPE_PERFORMANCE,"IU_POTENCY","IU_POTENCY_DESC",volumeTypeDao.getByName("V_POTENCY"),volumeFactorDao.getByName("VF_WATTS")));
			ius.add(new IntensityUnit(24,IntensityUnit.IU_TYPE_PERFORMANCE,"IU_POTENCY_PERCENT","IU_POTENCY_PERCENT_DESC",volumeTypeDao.getByName("V_PERCENT"),volumeFactorDao.getByName("VF_PERCENT")));
			ius.add(new IntensityUnit(25,IntensityUnit.IU_TYPE_PERFORMANCE,"IU_RM","IU_RM_DESC",volumeTypeDao.getByName("V_REPETITION"),volumeFactorDao.getByName("VF_REPETITION")));
			ius.add(new IntensityUnit(26,IntensityUnit.IU_TYPE_PERFORMANCE,"IU_SPEED","IU_SPEED_DESC",volumeTypeDao.getByName("V_VELOCITY"),volumeFactorDao.getByName("VF_KM_H")));
			ius.add(new IntensityUnit(27,IntensityUnit.IU_TYPE_PERFORMANCE,"IU_SPEED_PERCENT","IU_SPEED_PERCENT_DESC",volumeTypeDao.getByName("V_PERCENT"),volumeFactorDao.getByName("VF_PERCENT")));
			ius.add(new IntensityUnit(28,IntensityUnit.IU_TYPE_PERFORMANCE,"IU_TORQUE_PEAK","IU_TORQUE_PEAK_DESC",volumeTypeDao.getByName("V_DUMMY"),volumeFactorDao.getByName("VF_DUMMY")));
			ius.add(new IntensityUnit(29,IntensityUnit.IU_TYPE_PHYSIOLOGIC,"IU_VO2","IU_VO2_DESC",volumeTypeDao.getByName("V_DUMMY"),volumeFactorDao.getByName("VF_DUMMY")));
			ius.add(new IntensityUnit(30,IntensityUnit.IU_TYPE_PHYSIOLOGIC,"IU_VO2_MAX_PERCENT","IU_VO2_MAX_PERCENT_DESC",volumeTypeDao.getByName("V_PERCENT"),volumeFactorDao.getByName("VF_PERCENT")));
			ius.add(new IntensityUnit(31,IntensityUnit.IU_TYPE_PHYSIOLOGIC,"IU_KCAL","IU_KCAL_DESC",volumeTypeDao.getByName("V_KCAL"),volumeFactorDao.getByName("VF_KCAL_H")));
			ius.add(new IntensityUnit(32,IntensityUnit.IU_TYPE_PHYSIOLOGIC,"IU_MAX_KCAL_PERCENT","IU_MAX_KCAL_PERCENT_DESC",volumeTypeDao.getByName("V_PERCENT"),volumeFactorDao.getByName("VF_PERCENT")));
			ius.add(new IntensityUnit(33,IntensityUnit.IU_TYPE_SUBJECTIVES,"IU_BORG","IU_BORG_DESC",volumeTypeDao.getByName("V_DUMMY"),volumeFactorDao.getByName("VF_DUMMY")));
			ius.add(new IntensityUnit(34,IntensityUnit.IU_TYPE_PHYSIOLOGIC,"IU_BPM","IU_BPM_DESC",volumeTypeDao.getByName("V_BPM"),volumeFactorDao.getByName("VF_BPM")));
			

			
			
			ius = iuDao.save(ius);	

		}
			
		return ius;
		
	}
	private void initVolumeTypes() {

		List<VolumeFactor> volFactors = new ArrayList<VolumeFactor>();
		List<VolumeType> volTypes = new ArrayList<VolumeType>();
		VolumeType volType;
		
		
		if(volumeFactorDao.list().isEmpty()){

			volFactors.add(new VolumeFactor("VF_BPM","Bpm",3,0,"#value*1","#value/1",false));
			volFactors.add(new VolumeFactor("VF_CV","CV",4,2,"#value*735.49875","#value/735.49875",false));
			volFactors.add(new VolumeFactor("VF_DISTANCE_CM","cm",3,2,"#value*0.01","#value/0.01",false));
			volFactors.add(new VolumeFactor("VF_DISTANCE_FT","ft",3,2,"#value*3.2808399","#value/3.2808399",false));
			volFactors.add(new VolumeFactor("VF_DISTANCE_KM","Km",2,3,"#value*1000","#value/1000",false));
			volFactors.add(new VolumeFactor("VF_DISTANCE_M","m",2,3,"#value*1","#value/1",false));
			volFactors.add(new VolumeFactor("VF_DISTANCE_MI","mi",3,2,"#value*0.000621371192","#value/0.000621371192",false));
			volFactors.add(new VolumeFactor("VF_DISTANCE_MM","mm",3,2,"#value*0.001","#value/0.001",false));
			volFactors.add(new VolumeFactor("VF_DISTANCE_YD","yd",3,2,"#value*1.0936133","#value/1.0936133",false));
			volFactors.add(new VolumeFactor("VF_DUMMY","",4,2,"#value*1","#value/1",false));
			volFactors.add(new VolumeFactor("VF_FOOT_S","Ft/s",2,3,"#value*3.2808399","#value/3.2808399",false));
			volFactors.add(new VolumeFactor("VF_HP","Hp",4,2,"#value*745.699872","#value/745.699872",false));
			volFactors.add(new VolumeFactor("VF_HZ","Hz",3,2,"#value*1","#value/1",false));
			volFactors.add(new VolumeFactor("VF_KG","Kg",4,2,"#value*1000","#value/1000",false));
			volFactors.add(new VolumeFactor("VF_KHZ","kHz",3,2,"#value*1000","#value/1000",false));
			volFactors.add(new VolumeFactor("VF_KM_H","Km/h",2,3,"#value*3.6","#value/3.6",false));
			volFactors.add(new VolumeFactor("VF_KWATTS","K/Watts",4,2,"#value*1000","#value/1000",false));
			volFactors.add(new VolumeFactor("VF_M_S","m/s",2,3,"#value*1","#value/1",false));
			volFactors.add(new VolumeFactor("VF_MG","mg",4,2,"#value*1","#value/1",false));
			volFactors.add(new VolumeFactor("VF_MHZ","mHz",4,2,"#value*1000000","#value/1000000",false));
			volFactors.add(new VolumeFactor("VF_MILES_H","mph",2,3,"#value*2.23693629","#value/2.23693629",false));
			volFactors.add(new VolumeFactor("VF_PACE_T_100FOOT","t/100Ft",2,3,"(1/#value)*3.2808399*100","(1/#value)*3.2808399*100",true));
			volFactors.add(new VolumeFactor("VF_PACE_T_100M","t/100m",2,3,"(1/#value)*100","(1/#value)*100",true));
			volFactors.add(new VolumeFactor("VF_PACE_T_FOOT","t/Ft",2,3,"(1/ #value)*3.2808399","(1/ #value)*3.2808399",true));
			volFactors.add(new VolumeFactor("VF_PACE_T_KM","t/Km",2,3,"(1/#value)*1000","(1/#value)*1000",true));
			volFactors.add(new VolumeFactor("VF_PACE_T_M","t/m",2,3,"1/#value","1/#value",true));
			volFactors.add(new VolumeFactor("VF_PACE_T_MILES","t/Mi",2,3,"(1/#value)*0.000621371192","(1/#value)*0.000621371192",true));
			volFactors.add(new VolumeFactor("VF_PERCENT","%",2,3,"#value*1","#value/1",false));
			volFactors.add(new VolumeFactor("VF_REPETITION","reps",4,0,"#value*1","#value/1",false));
			volFactors.add(new VolumeFactor("VF_RPE","RPE",0,2,"#value*1","#value/1",false));
			volFactors.add(new VolumeFactor("VF_TIME","",4,2,"#value*1","#value/1",true));
			volFactors.add(new VolumeFactor("VF_WATTS","Watts",4,2,"#value*1","#value/1",false));
			volFactors.add(new VolumeFactor("VF_KCAL_H","Kcal/H",4,2,"#value*1000","#value/1000",false));
			volFactors.add(new VolumeFactor("VF_KCAL_M","Kcal/m",4,0,"#value*1","#value/1",false));
			volFactors.add(new VolumeFactor("VF_MAX_KCAL","% Kcal",3,0,"#value*1","#value/1",false));




			volumeFactorDao.save(volFactors);
			
			volType = new VolumeType("V_REPETITION");
			volType.getVolumeFactors().add(volumeFactorDao.getByName("VF_REPETITION"));
			volTypes.add(volType);
			
			volType = new VolumeType("V_DISTANCE");
			volType.getVolumeFactors().add(volumeFactorDao.getByName("VF_DISTANCE_KM"));
			volType.getVolumeFactors().add(volumeFactorDao.getByName("VF_DISTANCE_M"));
			volType.getVolumeFactors().add(volumeFactorDao.getByName("VF_DISTANCE_CM"));
			volType.getVolumeFactors().add(volumeFactorDao.getByName("VF_DISTANCE_MM"));
			volType.getVolumeFactors().add(volumeFactorDao.getByName("VF_DISTANCE_MI"));
			volType.getVolumeFactors().add(volumeFactorDao.getByName("VF_DISTANCE_YD"));
			volType.getVolumeFactors().add(volumeFactorDao.getByName("VF_DISTANCE_FT"));
			volTypes.add(volType);

			volType = new VolumeType("V_TIME");
			volType.getVolumeFactors().add(volumeFactorDao.getByName("VF_TIME"));
			volTypes.add(volType);

			volType = new VolumeType("V_VELOCITY");
			volType.getVolumeFactors().add(volumeFactorDao.getByName("VF_M_S"));
			volType.getVolumeFactors().add(volumeFactorDao.getByName("VF_KM_H"));
			volType.getVolumeFactors().add(volumeFactorDao.getByName("VF_FOOT_S"));
			volType.getVolumeFactors().add(volumeFactorDao.getByName("VF_MILES_H"));
			volType.getVolumeFactors().add(volumeFactorDao.getByName("VF_PACE_T_M"));
			volType.getVolumeFactors().add(volumeFactorDao.getByName("VF_PACE_T_100M"));
			volType.getVolumeFactors().add(volumeFactorDao.getByName("VF_PACE_T_KM"));
			volType.getVolumeFactors().add(volumeFactorDao.getByName("VF_PACE_T_FOOT"));
			volType.getVolumeFactors().add(volumeFactorDao.getByName("VF_PACE_T_100FOOT"));
			volType.getVolumeFactors().add(volumeFactorDao.getByName("VF_PACE_T_MILES"));
			volTypes.add(volType);
			
			volType = new VolumeType("V_WEIGHT");
			volType.getVolumeFactors().add(volumeFactorDao.getByName("VF_MG"));
			volType.getVolumeFactors().add(volumeFactorDao.getByName("VF_KG"));
			volTypes.add(volType);
			
			volType = new VolumeType("V_PERCENT");
			volType.getVolumeFactors().add(volumeFactorDao.getByName("VF_PERCENT"));
			volTypes.add(volType);
			
			volType = new VolumeType("V_POTENCY");
			volType.getVolumeFactors().add(volumeFactorDao.getByName("VF_WATTS"));
			volType.getVolumeFactors().add(volumeFactorDao.getByName("VF_KWATTS"));
			volType.getVolumeFactors().add(volumeFactorDao.getByName("VF_HP"));
			volType.getVolumeFactors().add(volumeFactorDao.getByName("VF_CV"));
			volTypes.add(volType);
			
			volType = new VolumeType("V_SUBJECTIVE");
			volType.getVolumeFactors().add(volumeFactorDao.getByName("VF_BORG"));
			volTypes.add(volType);
			
			volType = new VolumeType("V_HERTZ");
			volType.getVolumeFactors().add(volumeFactorDao.getByName("VF_HZ"));
			volType.getVolumeFactors().add(volumeFactorDao.getByName("VF_KHZ"));
			volType.getVolumeFactors().add(volumeFactorDao.getByName("VF_MHZ"));
			volTypes.add(volType);

			volType = new VolumeType();
			volType.setName("V_DUMMY");
			volType.getVolumeFactors().add(volumeFactorDao.getByName("VF_DUMMY"));
			volTypes.add(volType);
			
			volType = new VolumeType();
			volType.setName("V_KCAL");
			volType.getVolumeFactors().add(volumeFactorDao.getByName("VF_KCAL_H"));
			volType.getVolumeFactors().add(volumeFactorDao.getByName("VF_KCAL_M"));

			volType = new VolumeType();
			volType.setName("V_BPM");
			volType.getVolumeFactors().add(volumeFactorDao.getByName("VF_BPM"));

			
			volTypes.add(volType);

			
			volumeTypeDao.save(volTypes);
		}
	}

	private List<Execution> initExecutions() {
		
		List<Execution> executions;
		Execution execution;
		
		executions = executionDao.list();
		
		if(executions.isEmpty()){
			execution = new Execution();
			execution.setName("E_DYNAMIC");			
			execution.setDescription("");
			executions.add(execution);

			execution = new Execution();
			execution.setName("E_ECCENTRIC");			
			execution.setDescription("");
			executions.add(execution);

			execution = new Execution();
			execution.setName("E_ISOMETRIC");			
			execution.setDescription("");
			executions.add(execution);

			execution = new Execution();
			execution.setName("E_AEROBIC");			
			execution.setDescription("");
			executions.add(execution);

			execution = new Execution();
			execution.setName("E_STATIC");			
			execution.setDescription("");
			executions.add(execution);

			execution = new Execution();
			execution.setName("E_BILATERAL");			
			execution.setDescription("");
			executions.add(execution);
			
			execution = new Execution();
			execution.setName("E_UNILATERAL");			
			execution.setDescription("");
			executions.add(execution);
			
			
//			execution = new Execution();
//			execution.setName("E_ISOKINETIC");			
//			execution.setDescription("");
//			executions.add(execution);
//
//			execution = new Execution();
//			execution.setName("E_ANAEROBIC_LACTIC");			
//			execution.setDescription("");
//			executions.add(execution);
//
//			execution = new Execution();
//			execution.setName("E_ANAEROBIC_ALACTIC");			
//			execution.setDescription("");
//			executions.add(execution);

			
			executions = executionDao.save(executions);			
		}
		
		return executions;

	}

	private List<TrainingType> initTrainingTypes() {
	
		List<TrainingType> tts;
		List<PhysicalCapacity> pcs;
		TrainingType trainingType;

		if(pcDao.list().isEmpty()){
			pcs = new ArrayList<PhysicalCapacity>();
			pcs.add(new PhysicalCapacity());
			pcs.add(new PhysicalCapacity("PC_ANATOMICAL_ADAPTATION","PC_DESC_ANATOMICAL_ADAPTATION"));
			pcs.add(new PhysicalCapacity("PC_RESISTANCE_AEROBICS_STRENGTH","PC_DESC_RESISTANCE_AEROBICS_STRENGTH"));
			pcs.add(new PhysicalCapacity("PC_RESISTANCE_OF_ANAEROBIC_POWER","PC_DESC_RESISTANCE_OF_ANAEROBIC_POWER"));
			pcs.add(new PhysicalCapacity("PC_POTENCY","PC_DESC_POTENCY"));
			pcs.add(new PhysicalCapacity("PC_HYPERTROPHY","PC_DESC_HYPERTROPHY"));
			pcs.add(new PhysicalCapacity("PC_MAXIMUM_FORCE","PC_DESC_MAXIMUM_FORCE"));
			pcs.add(new PhysicalCapacity("PC_1RM","PC_DESC_1RM"));
			pcs.add(new PhysicalCapacity("PC_RECOVERY","PC_DESC_RECOVERY"));
			pcs.add(new PhysicalCapacity("PC_AEROBIC_RESISTANCE_SUBMAXIMAL","PC_DESC_AEROBIC_RESISTANCE_SUBMAXIMAL"));
			pcs.add(new PhysicalCapacity("PC_MAXIMUM_AEROBIC_RESISTANCE","PC_DESC_MAXIMUM_AEROBIC_RESISTANCE"));
			pcs.add(new PhysicalCapacity("PC_TIME","PC_DESC_TIME"));
			pcs.add(new PhysicalCapacity("PC_MAXIMUM_AEROBIC_CAPACITY","PC_DESC_MAXIMUM_AEROBIC_CAPACITY"));
			pcs.add(new PhysicalCapacity("PC_POWER_AEROBIC_SUBMAXIMAL","PC_DESC_POWER_AEROBIC_SUBMAXIMAL"));
			pcs.add(new PhysicalCapacity("PC_MAXIMUM_AEROBIC_POWER","PC_DESC_MAXIMUM_AEROBIC_POWER"));
			pcs.add(new PhysicalCapacity("PC_ANAEROBIC_ENDURANCE_SUBMAXIMAL","PC_DESC_ANAEROBIC_ENDURANCE_SUBMAXIMAL"));
			pcs.add(new PhysicalCapacity("PC_MAXIMUM_ANAEROBIC_POWER","PC_DESC_MAXIMUM_ANAEROBIC_POWER"));
			pcs.add(new PhysicalCapacity("PC_HEATING","PC_DESC_HEATING"));
			pcs.add(new PhysicalCapacity("PC_RELAX_MUSCLES","PC_DESC_RELAX_MUSCLES"));
			pcs.add(new PhysicalCapacity("PC_INCREASE_JOINT_RANGE","PC_DESC_INCREASE_JOINT_RANGE"));
			pcDao.save(pcs);
		}
		
		tts = ttDao.list();
		
		if(tts.isEmpty()){
			
//			trainingType = new TrainingType();
//			trainingType.setName("TT_FUNCTIONAL");
//			trainingType.getVolumeTypes().add(volumeTypeDao.getByName("V_REPETITION"));
//			trainingType.getVolumeTypes().add(volumeTypeDao.getByName("V_TIME"));
//			trainingType.getPhysicalCapacitys().add(pcDao.getByName("PC_ANATOMICAL_ADAPTATION"));
//			trainingType.getPhysicalCapacitys().add(pcDao.getByName("PC_RESISTANCE_AEROBICS_STRENGTH"));
//			trainingType.getPhysicalCapacitys().add(pcDao.getByName("PC_RESISTANCE_OF_ANAEROBIC_POWER"));
//			trainingType.getPhysicalCapacitys().add(pcDao.getByName("PC_POTENCY"));
//			trainingType.getPhysicalCapacitys().add(pcDao.getByName("PC_HYPERTROPHY"));
//			trainingType.getPhysicalCapacitys().add(pcDao.getByName("PC_MAXIMUM_FORCE"));
//			trainingType.getPhysicalCapacitys().add(pcDao.getByName("PC_1RM"));
//			tts.add(trainingType);

			
			trainingType = new TrainingType();
			trainingType.setName("TT_STRENGTH");
			trainingType.setIntensityVolume(volumeTypeDao.getByName("V_TIME"));
			trainingType.getVolumeTypes().add(volumeTypeDao.getByName("V_REPETITION"));
			trainingType.getVolumeTypes().add(volumeTypeDao.getByName("V_TIME"));
			trainingType.getPhysicalCapacitys().add(pcDao.getByName("PC_ANATOMICAL_ADAPTATION"));
			trainingType.getPhysicalCapacitys().add(pcDao.getByName("PC_RESISTANCE_AEROBICS_STRENGTH"));
			trainingType.getPhysicalCapacitys().add(pcDao.getByName("PC_RESISTANCE_OF_ANAEROBIC_POWER"));
			trainingType.getPhysicalCapacitys().add(pcDao.getByName("PC_POTENCY"));
			trainingType.getPhysicalCapacitys().add(pcDao.getByName("PC_HYPERTROPHY"));
			trainingType.getPhysicalCapacitys().add(pcDao.getByName("PC_MAXIMUM_FORCE"));
			trainingType.getPhysicalCapacitys().add(pcDao.getByName("PC_1RM"));

			tts.add(trainingType);


			trainingType = new TrainingType();
			trainingType.setName("TT_LOCOMOTION");
			trainingType.setIntensityVolume(volumeTypeDao.getByName("V_VELOCITY"));
			trainingType.getVolumeTypes().add(volumeTypeDao.getByName("V_DISTANCE"));
			trainingType.getVolumeTypes().add(volumeTypeDao.getByName("V_TIME"));
			trainingType.getPhysicalCapacitys().add(pcDao.getByName("PC_RECOVERY"));
			trainingType.getPhysicalCapacitys().add(pcDao.getByName("PC_AEROBIC_RESISTANCE_SUBMAXIMAL"));
			trainingType.getPhysicalCapacitys().add(pcDao.getByName("PC_MAXIMUM_AEROBIC_RESISTANCE"));
			trainingType.getPhysicalCapacitys().add(pcDao.getByName("PC_TIME"));
			trainingType.getPhysicalCapacitys().add(pcDao.getByName("PC_MAXIMUM_AEROBIC_CAPACITY"));
			trainingType.getPhysicalCapacitys().add(pcDao.getByName("PC_POWER_AEROBIC_SUBMAXIMAL"));
			trainingType.getPhysicalCapacitys().add(pcDao.getByName("PC_MAXIMUM_AEROBIC_POWER"));
			trainingType.getPhysicalCapacitys().add(pcDao.getByName("PC_ANAEROBIC_ENDURANCE_SUBMAXIMAL"));
			trainingType.getPhysicalCapacitys().add(pcDao.getByName("PC_MAXIMUM_ANAEROBIC_POWER"));
			tts.add(trainingType);
		
			trainingType = new TrainingType();
			trainingType.setName("TT_FLEXIBILITY");
			trainingType.setIntensityVolume(volumeTypeDao.getByName("V_TIME"));
			trainingType.getVolumeTypes().add(volumeTypeDao.getByName("V_REPETITION"));
			trainingType.getVolumeTypes().add(volumeTypeDao.getByName("V_TIME"));
			trainingType.getPhysicalCapacitys().add(pcDao.getByName("PC_HEATING"));
			trainingType.getPhysicalCapacitys().add(pcDao.getByName("PC_RELAX_MUSCLES"));
			trainingType.getPhysicalCapacitys().add(pcDao.getByName("PC_INCREASE_JOINT_RANGE"));
			tts.add(trainingType);
			
			trainingType = new TrainingType();
			trainingType.setName("TT_PLYOMETRIC");
			trainingType.setIntensityVolume(volumeTypeDao.getByName("V_TIME"));
			trainingType.getVolumeTypes().add(volumeTypeDao.getByName("V_REPETITION"));
			trainingType.getPhysicalCapacitys().add(pcDao.getByName("PC_ANATOMICAL_ADAPTATION"));
			trainingType.getPhysicalCapacitys().add(pcDao.getByName("PC_RESISTANCE_AEROBICS_STRENGTH"));
			trainingType.getPhysicalCapacitys().add(pcDao.getByName("PC_RESISTANCE_OF_ANAEROBIC_POWER"));
			trainingType.getPhysicalCapacitys().add(pcDao.getByName("PC_POTENCY"));
			trainingType.getPhysicalCapacitys().add(pcDao.getByName("PC_HYPERTROPHY"));
			trainingType.getPhysicalCapacitys().add(pcDao.getByName("PC_MAXIMUM_FORCE"));
			trainingType.getPhysicalCapacitys().add(pcDao.getByName("PC_1RM"));
			tts.add(trainingType);

			trainingType = new TrainingType();
			trainingType.setName("TT_RECOVER");
			trainingType.setIntensityVolume(volumeTypeDao.getByName("V_TIME"));
			trainingType.getVolumeTypes().add(volumeTypeDao.getByName("V_TIME"));

			tts.add(trainingType);
			
			tts = ttDao.create(tts);
		}
		
		return tts;
			
	}


	private void initDevData() {

	}


	private void initPhoto() {
		List<Photo> photos = new ArrayList<Photo>();
		
		if(photoDao.list().isEmpty()){
			photos.add(new Photo("default_logo_wide",80,250,"default_logo_wide.jpg"));
			photos.add(new Photo("default_logo",120,100,"default_logo.jpg"));
			photos.add(new Photo("default_user_photo",120,100,"user_photo.jpg"));
			photos.add(new Photo("default_equipment",320,240,"default_equipment.jpg"));
			photos.add(new Photo("default_exercise",320,240,"default_exercise.jpg"));

			
			photoDao.save(photos);
		}

		
	}

	private void initThemes() {
		
		if(this.themeDao.list().isEmpty()){
			List<Theme> advancedThemes = new ArrayList<Theme>();
	        advancedThemes.add(new Theme("afterdark", "afterdark.png"));
	        advancedThemes.add(new Theme("afternoon", "afternoon.png"));
	        advancedThemes.add(new Theme("afterwork", "afterwork.png"));
	        advancedThemes.add(new Theme("aristo", "aristo.png"));
	        advancedThemes.add(new Theme("black-tie", "black-tie.png"));
	        advancedThemes.add(new Theme("blitzer", "blitzer.png"));
	        advancedThemes.add(new Theme("bluesky", "bluesky.png"));
	        advancedThemes.add(new Theme("bootstrap", "bootstrap.png"));
	        advancedThemes.add(new Theme("casablanca", "casablanca.png"));
	        advancedThemes.add(new Theme("cruze", "cruze.png"));
	        advancedThemes.add(new Theme("cupertino", "cupertino.png"));
	        advancedThemes.add(new Theme("dark-hive", "dark-hive.png"));
	        advancedThemes.add(new Theme("delta", "delta.png"));
	        advancedThemes.add(new Theme("dot-luv", "dot-luv.png"));
	        advancedThemes.add(new Theme("eggplant", "eggplant.png"));
	        advancedThemes.add(new Theme("excite-bike", "excite-bike.png"));
	        advancedThemes.add(new Theme("flick", "flick.png"));
	        advancedThemes.add(new Theme("glass-x", "glass-x.png"));
	        advancedThemes.add(new Theme("home", "home.png"));
	        advancedThemes.add(new Theme("hot-sneaks", "hot-sneaks.png"));
	        advancedThemes.add(new Theme("humanity", "humanity.png"));
	        advancedThemes.add(new Theme("le-frog", "le-frog.png"));
	        advancedThemes.add(new Theme("midnight", "midnight.png"));
	        advancedThemes.add(new Theme("mint-choc", "mint-choc.png"));
	        advancedThemes.add(new Theme("overcast", "overcast.png"));
	        advancedThemes.add(new Theme("pepper-grinder", "pepper-grinder.png"));
	        advancedThemes.add(new Theme("redmond", "redmond.png"));
	        advancedThemes.add(new Theme("rocket", "rocket.png"));
	        advancedThemes.add(new Theme("sam", "sam.png"));
	        advancedThemes.add(new Theme("smoothness", "smoothness.png"));
	        advancedThemes.add(new Theme("south-street", "south-street.png"));
	        advancedThemes.add(new Theme("start", "start.png"));
	        advancedThemes.add(new Theme("sunny", "sunny.png"));
	        advancedThemes.add(new Theme("swanky-purse", "swanky-purse.png"));
	        advancedThemes.add(new Theme("trontastic", "trontastic.png"));
	        advancedThemes.add(new Theme("ui-darkness", "ui-darkness.png"));
	        advancedThemes.add(new Theme("ui-lightness", "ui-lightness.png"));
	        advancedThemes.add(new Theme("vader", "vader.png"));

        	try {
				this.themeDao.save(advancedThemes);
			} catch (ExceptionDao e) {
				e.printStackTrace();
			}
		}
	}
}
